package com.yu.markdowntohtml.utils;

import java.io.*;

/**
 * 读取文件
 *
 * @author lloverain
 * @Data 2021-11-10 10:57
 **/
public class FileUtil {
    public static String readByLines(String path) {
        String content = null;
        try {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(new FileInputStream(path), "utf-8"));

            StringBuffer sb = new StringBuffer();
            String temp = null;
            while ((temp = bufferedReader.readLine()) != null) {
                sb.append(temp + "\n");
            }

            content = sb.toString();
            bufferedReader.close();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return content;
    }
}
